import { ApiCall } from "tsrpc";
import { ReqExchange_gold, ResExchange_gold } from "../../../../shared/master/bag/function/PtlExchange_gold";
import { player, wallet_key } from "../../../../model/fight/body/player";

export default async function (call: ApiCall<ReqExchange_gold, ResExchange_gold>) {
    call.succ({})
    if (call.req.num <= 0) {
        call.req.num = 1;
    }
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-15', v: call.req.num }], false, '金币兑换', true);
    if (!res.state) {
        return;
    }
    user.wallet_change(wallet_key.gold, call.req.num);
}